import instance from './instance';
import configs from '../config';

function getAuth(appId, redirectUri) {
    return instance({
        method: 'get',
        url: '/user/mp/auth',
        params: {
            appId, redirectUri
        }
    });
}

function getJsTicket(url, appId) {
    return instance({
        method: 'get',
        url: '/share/mp/jsticket',
        params: {
            appId, url
        }
    });
}

function getUserInfo() {
    return instance({
        method: 'get',
        url: '/user/common/get_user_info'
    });
}

function getItemsList() {
    return instance({
        method: 'get',
        url: '/item/common/list'
    });
}

function getUserItemsList() {
    return instance({
        method: 'get',
        url: '/item/common/get_user_items'
    });
}

function createOrder(itemId, num, vip, productType) {
    return instance({
        method: 'post',
        url: `/pay/common/create_order?token=${configs.token}&productType=${configs.productType}`,
        data: {
            itemId, num, vip, productType
        }
    });
}
export default {
    getAuth,
    getJsTicket,
    getUserInfo,
    getItemsList,
    getUserItemsList,
    createOrder
};
